//
//  MainVC.m
//  核心动画
//
//  Created by chichaojituan521 on 2017/5/27.
//  Copyright © 2017年 linch. All rights reserved.
//

#import "MainVC.h"
#import "PushAnimation.h"
#import "PopAnimation.h"
#import "AnimationVC1.h"
#import "AnimationVC2.h"
#import "ViewControllerTouch.h"
#import "ViewControllerDraw.h"
#import "ViewControllerDrawBoard.h"
#import "ViewControllerBezier.h"
#import "ViewControllerBeizerAni.h"
#import "ViewControllerWave.h"
#import "QiuAniVC.h"
#import "XNViewController.h"
@interface MainVC ()<UINavigationControllerDelegate>//自定义push动画
{
    PushAnimation *customPush;
    PopAnimation *customPop;
}

@end

@implementation MainVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    //自定义push动画和loadView 方法冲突   导致push进黑屏界面
    customPush = [[PushAnimation alloc] init];
    customPop = [[PopAnimation alloc] init];
    self.navigationController.delegate = self;
    
  
    NSArray *arrName = @[@"动画视图1",@"动画视图2",@"小球移动",@"画图",@"画板",@"贝塞尔",@"贝塞尔动画",@"波浪进度",@"小球动画",@"旋钮动画",@"11",@"12",@"13",@"14",@"15",@"16",@"17",@"18",@"19",@"20",@"21",@"22",@"23",@"24",@"25"];
    
    
    for (int i = 0;i<25 ; i++) {
        UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
        btn.titleLabel.font = [UIFont systemFontOfSize:13];
        btn.backgroundColor = [UIColor orangeColor];
        float JG = (self.view.frame.size.width - 70*5)/6.0;
        float btnx = JG + (JG + 70)*(i%5);
        float btny = 200 + (JG+30)*(i/5);
        btn.frame = CGRectMake(btnx, btny, 70, 30);
        [self.view addSubview:btn];
        btn.tag = i;
        [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
        [btn setTitle:arrName[i] forState:UIControlStateNormal];
    }

}
-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden = YES;
}

#pragma  mark -- 自定义pushpop 动画
-(id<UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController animationControllerForOperation:(UINavigationControllerOperation)operation fromViewController:(UIViewController *)fromVC toViewController:(UIViewController *)toVC
{
    if (operation == UINavigationControllerOperationPush)
    {
        return customPush;
    }
    else if (operation == UINavigationControllerOperationPop)
    {
        return customPop;
    }
    else
    {
        return nil;
    }
}

-(void)btnClick:(UIButton *)btn
{
    switch (btn.tag) {
        case 0:
            [self jumpToAnimationVC1];
            break;
        case 1:
            [self jumpToAnimationVC2];
            break;
        case 2:
            [self jumpToViewControllerTouch];
            break;
        case 3:
            [self jumpToViewControllerDraw];
            break;
        case 4:
            [self jumpToViewControllerDrawBoard];
            break;
        case 5:
            [self jumpToViewControllerBezier];
            break;
        case 6:
            [self jumpToViewControllerBezierAnimation];
            break;
        case 7:
            [self jumpToViewControllerWaveAnimation];
            break;
        case 8:
            [self jumpToViewControllerQiuXAni];
            break;
        case 9:
            [self jumpToViewControllerXN];
            break;
        default:
            break;
    }
}
-(void)jumpToAnimationVC1
{
    AnimationVC1 *VCAni1 = [[AnimationVC1 alloc]init];
    [self.navigationController pushViewController:VCAni1 animated:YES];
    
}
-(void)jumpToAnimationVC2
{
    AnimationVC2 *VCAni2 = [[AnimationVC2 alloc]init];
    [self.navigationController pushViewController:VCAni2 animated:YES];
    
}
-(void)jumpToViewControllerTouch
{
    ViewControllerTouch *VCTouch = [[ViewControllerTouch alloc]init];
    [self.navigationController pushViewController:VCTouch animated:YES];
    
}
-(void)jumpToViewControllerDraw
{
    ViewControllerDraw *VCDraw = [[ViewControllerDraw alloc]init];
    [self.navigationController pushViewController:VCDraw animated:YES];
}
-(void)jumpToViewControllerDrawBoard
{
    ViewControllerDrawBoard *VCDrawB = [[ViewControllerDrawBoard alloc]init];
    [self.navigationController pushViewController:VCDrawB animated:YES];
}
-(void)jumpToViewControllerBezier
{
    ViewControllerBezier *VCBezier = [[ViewControllerBezier alloc]init];
    [self.navigationController pushViewController:VCBezier animated:YES];
}
-(void)jumpToViewControllerBezierAnimation
{
    ViewControllerBeizerAni *VCBAni = [[ViewControllerBeizerAni alloc]init];
    [self.navigationController pushViewController:VCBAni animated:YES];
}
-(void)jumpToViewControllerWaveAnimation
{
    ViewControllerWave *VCWave = [[ViewControllerWave alloc]init];
    [self.navigationController pushViewController:VCWave animated:YES];
}
- (void)jumpToViewControllerQiuXAni
{
    QiuAniVC *vc = [[QiuAniVC alloc]init];
    [self.navigationController pushViewController:vc animated:YES];
}
- (void)jumpToViewControllerXN
{
    XNViewController *vc = [[XNViewController alloc]init];
    [self.navigationController pushViewController:vc animated:YES];
}
@end
